<?php

/**
 * Form Image Element class
 *
 * @author Mathieu Pheulpin - sokaru91@gmail.com
 *
 */
class Mac_Form_Element_Image extends Mac_Form_Element_Abstract
{
    protected $source;

    public function __construct ($name, $src, $label = null)
    {
        parent::__construct($name);
        $this->value = $name;
        $this->source = $src;
        $this->label = $label;
    }

    public function __toString ()
    {
        return '<input
            type="image"
            id="'.$this->id.'"
            name="'.$this->name.'"
            value="'.$this->value.'"
            src="'.$this->source.'"
            '.(($this->label !== null) ? 'title="'.$this->label.'" alt="'.$this->label.'"' : '').'
            '.((count($this->class) > 0) ? 'class="'.implode(' ', $this->class).'"' : '').'
            '.$this->printOptions().'
        />';
    }
}